use chrono::{DateTime, NaiveDate, Utc};
use super::assets::AssetsDao;
use serde::{Serialize,Deserialize};
#[derive(Debug,PartialEq, PartialOrd)]
pub enum UserRoleEnum {
    Anon=1<<1,
    Student=1<<2,
    SGLeader=1<<3,
    Admin=1<<4,
    SuperAdmin=1<<5
}
impl Into<i32> for UserRoleEnum {
    fn into(self) -> i32 {
        self as i32
    }
}

declare_dao!(UserDao {
    id:i64,
    nickname:String,
    name:Option<String>,
    avatar:Option<i64>,
    gender:i32,
    birthday:Option<NaiveDate>,
    email:Option<String>,
    qq:Option<String>,
    wechat:Option<String>,
    comment:Option<String>,
    created_at:DateTime<Utc>,
    updated_at:DateTime<Utc>
};"users";i64;id);

#[derive(Debug,Clone,Serialize,Deserialize)]
pub struct UserRegister {
    pub nickname:String,
    pub name:Option<String>,
    pub avatar:Option<String>,
    pub gender:i32,
    pub birthday:Option<NaiveDate>,
    pub email:Option<String>,
    pub qq:Option<String>,
    pub wechat:Option<String>,
    pub comment:Option<String>
}


impl_session_key!(UserDao,"user_id");

declare_dao!(UserExpand {
    id:i64,
    nickname:String,
    name:Option<String>,
    avatar:Option<AssetsDao>,
    gender:i32,
    birthday:Option<NaiveDate>,
    email:Option<String>,
    qq:Option<String>,
    wechat:Option<String>,
    comment:Option<String>,
    created_at:DateTime<Utc>,
    updated_at:DateTime<Utc>
});


declare_dao!(UserRole {
    user_id:i64,
    role:i32
};"user_role";i64;user_id);